<include file="Public/header" />
<include file="Public/menu" />
<link rel="stylesheet" href="/Public/admin/adminlte/bootstrap/css/bootstrap-switch.min.css">
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            店铺配置
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 店铺配置</a></li>
            <li class="active">快递运费模板</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content"><div class="row"><div class="col-md-12"><div class="box">
        <div class="box-header">

            <div class="btn-group pull-left" style="margin-right: 10px">
                <a href="/admin/freight/dlytmpAdd" class="btn btn-sm btn-success"><i class="fa fa-save"></i>&nbsp;&nbsp;新增快递运费模板</a>
            </div>

        </div>
        <!-- /.box-header -->
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <tbody>
                <tr>
                    <th></th>
                    <th>ID</th>
                    <th>运费模板名称</th>
                    <th>开关(同时只能启用一个)</th>
                    <th>操作</th>
                </tr>
                <foreach name="dlytmplist" item="v">
                <tr>
                    <td></td>
                    <td>{$v.tmp_id}</td>
                    <td>{$v.tmpname}</td>
                    <td>
                        <div class="switch">
                            <input type="checkbox" name="state" data-size="mini" data-id="{$v.tmp_id}" data-on-text="启用" data-off-text="禁用" <if condition="$v['active'] eq 1 ">checked</if>>
                        </div>
                    </td>
                    <td>
                        <a href="/admin/freight/dlytmpUpdate/id/{$v.tmp_id}"><i class="fa fa-edit"></i></a>
                        <a onclick="if(confirm('确定删除?')==false)return false;" href="/admin/freight/dlytmpDelete/id/{$v.tmp_id}" data-id="31" class="_delete"><i class="fa fa-trash"></i></a>
                    </td>
                </tr>
                </foreach>
                </tbody>
            </table>
        </div>


        <!-- /.box-body -->
    </div></div></div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer" />
<script src="__PUBLIC__/admin/adminlte/bootstrap/js/bootstrap-switch.min.js"></script>
<script>
    $(function(argument) {
        $('.switch [type="checkbox"]').bootstrapSwitch();

        $('input[name="state"]').on('switchChange.bootstrapSwitch', function (event, state) {
            //return $("input[name=state]").bootstrapSwitch('state', false);return false;
            var tmp_id = $(this).data('id');
            var _tr = $(this).parents('tr');
            var others = _tr.siblings().find('input[name=state]');
            //console.log(others);return false;
            $.ajax({
                type: 'get',
                url: "{:U('changeStatus')}",
                data: {tmp_id: tmp_id, state: state},
                success: function (msg) {
                    if (msg.data) {
                        return others.bootstrapSwitch('state', false);
                    }
                },
                error: function (msg) {
                    alert(msg.message);
                }
            })
        });
    });
</script>